<!--
 * @FilePath: src/views/Dashboard/ColGroup.vue
 * @Description: ColGroup.vue
-->
<template>
  <colgroup class="col-group">
    <col v-for="(w, index) in colums" :key="'_col_' + index" :width="w + '%'" />
  </colgroup>
</template>

<script>
export default {
  name: "ColGroup",
  props: { cols: { type: [Number, Array], default: () => [10, 10, 10] } },
  computed: {
    colums() {
      if (Array.isArray(this.cols)) {
        const sum = this.cols.reduce((a, c) => a + Number(c), 0)
        return this.cols.map(t => (100.0 * t) / (sum || 1.0))
      } else {
        return new Array(this.cols).fill(100.0 / this.cols)
      }
    }
  }
}
</script>
